import {RouteConfig} from 'vue-router'
import Layout from '@/layout/index.vue'
import 'nprogress/nprogress.css'

//  本地添加之后，登录系统管理员，点击上传菜单到服务器
//  上传之后会覆盖服务端的修改数据

//  *必备字段  path  路径（唯一）
//  *必备字段  meta.type    (1=目录  2=菜单 3=目录按钮 4=菜单按钮)
//  *必备字段  component    组件位置
//   可有可无  redirect    点击重定向
//   可有可无  children[]    子路由
//  *必备字段  meta.title     标题
//  *必备字段  meta.sort     排序
//  必备字段  meta.hidden  展示状态（1=展示，2=隐藏）
//  *必备字段  meta.icon    图标
//   可有可无  meta.alwaysShow    是否可以关闭（1=不可关闭，2=可以关闭）
//   可有可无  meta.name    组件名
//   可有可无  meta.affix   不知掉

/**
 *系统相关 1000
 */
export const systemRouter: RouteConfig[] = [
    /**
     * 系统管理
     */
    {
        path: '/system',
        component: Layout,
        redirect: '/system/dict',
        meta: {type: "1", title: '系统管理', icon: 'excel', sort: '1000'},
        children: [
            //菜单
            {
                path: '/system/menu/list',
                component: () => import('@/views/system/menu/Menu.vue'),
                name: 'Menu',
                meta: {type: "2", icon: 'excel', title: '菜单管理', sort: '1000'}
            },

            //用户
            {
                path: '/system/user/list',
                component: () => import('@/views/system/user/list.vue'),
                name: 'UserList',
                meta: {type: "2", icon: 'excel', title: '用户列表', sort: '1000'}
            }, {
                path: '/system/user/insert',
                component: () => import('@/views/system/user/insert.vue'),
                name: 'UserInsert',
                meta: {type: "2", icon: 'excel', title: '添加用户', sort: '1000', hidden: "2"}
            }, {
                path: '/system/user/edit',
                component: () => import('@/views/system/user/edit.vue'),
                name: 'UserEdit',
                meta: {type: "2", icon: 'excel', title: '编辑用户', sort: '1000', hidden: "2"}
            }, {
                path: '/system/user/info',
                component: () => import('@/views/system/user/info.vue'),
                name: 'UserInfo',
                meta: {type: "2", icon: 'excel', title: '用户详情', sort: '1000', hidden: "2"}
            },
        ]
    },
    {
        path: '/template',
        component: Layout,
        redirect: '/template/icons',
        meta: {type: "1", title: '模板管理', icon: 'excel', sort: '100'},
        children: [
            {
                path: '/template/icons',
                component: () => import('@/views/common/demo/Icons.vue'),
                name: 'Icons',
                meta: {type: "2", icon: 'excel', title: '图标Icon', sort: '105'}
            },
            {
                path: '/template/table',
                component: () => import('@/views/common/demo/Table.vue'),
                name: 'RequestLog',
                meta: {type: "2", icon: 'excel', title: '表格操作', sort: '106'}
            },
            //  {
            //     path: '/template/file',
            //     component: () => import('@/views/demo/File.vue'),
            //     name: 'File',
            //     meta: {type: "2", icon: 'excel', title: '文件操作', sort: '120'}
            // }
        ]
    },
];

/**
 *全局路由配置
 */
export const constantRoutes: RouteConfig[] = [
    {
        path: '/',
        component: Layout,
        name: "index",
        redirect: '/index',
        meta: {hidden: "2", type: "1", title: '首页', icon: 'dashboard'},
        children: [
            {
                path: '/index',
                component: () => import('@/views/common/index/Index.vue'),
                name: 'Index',
                meta: {type: "2", title: '首页', icon: 'dashboard', affix: "2", alwaysShow: "1",}
            }
        ]
    },
    // {
    //     path: '/login',
    //     name: "LoginSystem.vue",
    //     component: () => import('@/views/common/login/LoginDefault.vue'),
    //     meta: {
    //         type: "1", hidden: "2", title: "系统登录",
    //     }
    // },
    {
        path: '/login',
        name: "LoginSystem",
        component: () => import('@/views/LoginSystem.vue'),
        meta: {
            type: "1", hidden: "2", title: "系统登录",
        }
    }, {
        path: '/app/redirectLogin',
        name: "LoginToApp",
        component: () => import('@/views/LoginToApp.vue'),
        meta: {
            type: "1", hidden: "2", title: "系统登录",
        }
    },
    {
        path: '/402',
        name: "402",
        component: () => import('@/views/common/error/402.vue'),
        meta: {
            type: "1", hidden: "2", title: "权限不足",
        }
    },
    {
        path: '/404',
        name: "404",
        component: () => import('@/views/common/error/404.vue'),
        meta: {
            type: "1", hidden: "2", title: "页面不存在",
        }
    }
];

export const routerList: RouteConfig[] = [
    ...systemRouter,
];
